home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / include / sysdefs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  11.5 KB  |  424 lines

  1. #ifndef __SYSDEFS_H__
  2. #define __SYSDEFS_H__
  3. /*
  4.  *   $RCSfile: sysdefs.h,v $  
  5.  *   $Revision: 1.1.1.1 $  
  6.  *   $Date: 1996/05/04 21:55:08 $      
  7.  */ 
  8.  
  9. /**********************************************************************
  10. * EXODUS Database Toolkit Software
  11. * Copyright (c) 1991 Computer Sciences Department, University of
  12. *                    Wisconsin -- Madison
  13. * All Rights Reserved.
  14. *
  15. * Permission to use, copy, modify and distribute this software and its
  16. * documentation is hereby granted, provided that both the copyright
  17. * notice and this permission notice appear in all copies of the
  18. * software, derivative works or modified versions, and any portions
  19. * thereof, and that both notices appear in supporting documentation.
  20. *
  21. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  22. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  23. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  24. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  25. *
  26. * The EXODUS Project Group requests users of this software to return 
  27. * any improvements or extensions that they make to:
  28. *
  29. *   EXODUS Project Group 
  30. *     c/o David J. DeWitt and Michael J. Carey
  31. *   Computer Sciences Department
  32. *   University of Wisconsin -- Madison
  33. *   Madison, WI 53706
  34. *
  35. *     or exodus@cs.wisc.edu
  36. *
  37. * In addition, the EXODUS Project Group requests that users grant the 
  38. * Computer Sciences Department rights to redistribute these changes.
  39. **********************************************************************/
  40.  
  41. #ifndef __ESS_H__
  42. /* This file uses PROTO and BEGIN_EXTERNC from ess.h */
  43. #include "ess.h"
  44. #endif __ESS_H__
  45.  
  46. #if    defined(hpux)
  47.     /* ess.h defines MIN and MAX which hpux already defines */
  48. #    undef MIN
  49. #    undef MAX
  50. #endif
  51.  
  52. /* 
  53.  * ANSI C ********** *****************************************************
  54.  *                                                                       *
  55.  *                                                                       V
  56.  */
  57. #include <ctype.h>
  58. #include <errno.h>
  59. #include <limits.h>
  60.  
  61. #ifdef FLT_MAX
  62. /* grot - certain include files are NOT __STDC__:
  63.  * FLT_MAX is supposed to be defined in <float.h>, but some broken
  64.  * include files have it in <limits.h> as well.
  65.  */
  66. #undef FLT_MAX
  67. #endif
  68.  
  69. #include <limits.h>
  70. #include <setjmp.h>
  71. #include <signal.h>
  72. #include <stdio.h>
  73. #include <string.h>
  74.  
  75. #if defined(hpux)
  76. #    define BCOPY(a,b,c) bcopy((char*)a, (char*)b, c) 
  77. #    define BZERO(a,b) bzero((char*)a, b) 
  78. #elif defined(sgi)
  79. #    include <bstring.h>    /* bcopy prototypes */
  80. #else 
  81. #    define BCOPY bcopy 
  82. #    define BZERO bzero 
  83. #endif
  84.  
  85. #include <time.h>
  86.  
  87. /* var args stuff: */
  88. #include <stdarg.h>
  89.  
  90. /* some standard types, like size_t, as required by ANSI C */
  91. #include <stddef.h>
  92.  
  93. /* C library */
  94. #include <stdlib.h>
  95.  
  96. /* 
  97.  *                                                                       ^
  98.  *                                                                       *
  99.  *                                                                       *
  100.  * end of ANSI-C ********** **********************************************
  101.  */
  102.  
  103. /*
  104.  * types needed for system calls and just about everything else
  105.  */
  106. #include <sys/types.h>
  107.  
  108. /*
  109.  *
  110.  * handling of NULL ********************************************************
  111.  *  
  112.  * NULL is defined all over the /usr/include/*.h files, and its definitions
  113.  * aren't necessarily the same!
  114.  * So... before we use it, we'll undef it and redefine it here.
  115.  *
  116.  */
  117. #ifdef NULL
  118. #    undef NULL
  119. #    define NULL 0
  120. #endif
  121.  
  122. /* 
  123.  * system calls **********************************************************
  124.  * ATT C++ uses sysent.h but g++ does not.                                 *
  125.  * ATT C++ has sys/uio.h but g++ does not.                                 *
  126.  * g++ and cc use unistd.h, which doesn't necessarily include ALL          *
  127.  * sysents.                                                                 *
  128.  * What's really disgusting is that unistd has read,write,close, but not *
  129.  * open!!!!                                                               *
  130.  * open() is in fcntl.h for g++; it's in systent.h for ATT                 *
  131.  * so ... we include <fcntl.h> for everyone.                              *
  132.  * Now, the unfortunate thing about that is that for cc & ATT C++,         *
  133.  * fcntl.h     includes <sys/file.h> but g++ does not, so we include          *
  134.  * it here for      consistency.                                              *
  135.  *                                                                       *
  136.  *                                                                       *
  137.  *                                                                       *
  138.  *                                                                       V
  139.  */
  140.  
  141.  
  142. #if defined(__cplusplus)
  143. #    if !defined(__GNUC__) 
  144. #        include <sysent.h>
  145. #        if defined(sgi)
  146.         BEGIN_EXTERNC
  147.             int writev(int, const struct iovec *, int);
  148.         END_EXTERNC
  149. #        endif
  150. #    else
  151. #        include <sys/file.h>
  152. #        include <unistd.h>
  153. #        define writev     _______writev
  154. #        define readv      _______readv
  155. #        include "/usr/include/sys/uio.h"
  156. #        undef writev 
  157. #        undef readv
  158.  
  159.  
  160.         BEGIN_EXTERNC
  161.             int readv(int, const struct iovec *, int);
  162.             int writev(int, const struct iovec *, int);
  163.         END_EXTERNC
  164. #    endif 
  165. #else
  166. #    include <unistd.h>
  167. #endif 
  168.  
  169. #include  <fcntl.h>
  170.  
  171. /* 
  172.  * these two include files had better be protected against
  173.  * double inclusion:
  174.  */
  175. #if    defined(hpux)
  176.     /* sys/wait.h is included later due to interference in ipc.h */
  177. #else
  178. #    if defined(sgi)
  179.     /* sgi has ptrace defined in osfcn.h ! */
  180. #    else
  181. #        include <sys/wait.h>
  182. #    endif
  183. #endif
  184.  
  185. #include <sys/ptrace.h>
  186. #include <sys/time.h>
  187.  
  188.  
  189. /*
  190.  * getrusage() and setlinebuf() for hpux
  191.  * GROT
  192.  */
  193. #if    defined(hpux)
  194. #    include <sys/syscall.h>
  195. #    define getrusage(a, b)  syscall(SYS_GETRUSAGE, a, b)
  196. #    define setlinebuf(fp)     (setvbuf(fp, NULL, _IOLBF, 0), 0)
  197. #endif /* hpux */
  198.  
  199. /*
  200.  * getdtablesize doesn't seem to be defined for hpux or sgi
  201.  */
  202. #if    defined(hpux) || defined(sgi)
  203. #    define DTABLESIZE _POSIX_OPEN_MAX
  204. #else
  205. #    define DTABLESIZE getdtablesize()
  206. #endif
  207.  
  208. /* 
  209.  *                                                                       ^
  210.  *                                                                       *
  211.  *                                                                       *
  212.  *                                                                       *
  213.  * end of system calls      **********************************************
  214.  */
  215.  
  216.  
  217.  
  218. /* 
  219.  * net-related stuff *****************************************************
  220.  *                                                                       *
  221.  *                                                                       *
  222.  *                                                                       *
  223.  *                                                                       V
  224.  */
  225.  
  226. #include <sys/socket.h>
  227. #include <sys/ioctl.h>
  228. #if    defined(hpux)
  229. #include <sys/bsdtty.h>
  230. #endif
  231. #include <sys/uio.h>
  232.  
  233. #if (defined(__GNUC__) && defined(__cplusplus)) && (!defined(hpux)) && defined(mips)
  234. #   define htons htons_c
  235. #   define htonl htonl_c
  236. #   define ntohs ntohs_c
  237. #   define ntohl ntohl_c
  238. #endif
  239.  
  240. #include <netinet/in.h>
  241.  
  242. #if defined(__GNUC__) && defined(__cplusplus) && !defined(hpux)
  243.     BEGIN_EXTERNC
  244. #        include <arpa/inet.h>
  245.     END_EXTERNC
  246. #else
  247.     /* cc, cfront, and hpux compilers */
  248. #    include <arpa/inet.h>
  249. #endif
  250.  
  251. #include <netdb.h>
  252.  
  253.  
  254. /* 
  255.  * ATT C++ has prototype FUNCTION definitions for these (not macros).
  256.  * G++ ends up including c version of in.h, which gives
  257.  * us wrong definitions of the macros (no argument).  
  258.  * This kludge gets us around that.
  259.  * 
  260.  * HP-UX already has these.
  261.  */
  262. #if (defined(__GNUC__) && defined(__cplusplus)) && !defined(hpux)
  263.  
  264. #undef htons 
  265. #undef htonl 
  266. #undef ntohs 
  267. #undef ntohl 
  268.  
  269. #    ifdef _AIX
  270. #        define _shorttype_ short
  271. #        define _longtype_  long
  272. #    else
  273. #        define _shorttype_ u_short
  274. #        define _longtype_  u_long
  275. #    endif
  276.  
  277. BEGIN_EXTERNC
  278.         _shorttype_        htons(_shorttype_);
  279.         _shorttype_        ntohs(_shorttype_);
  280.         _longtype_        htonl(_longtype_);
  281.         _longtype_        ntohl(_longtype_);
  282. END_EXTERNC
  283. #endif
  284.  
  285. /* 
  286.  *                                                                       ^
  287.  *                                                                       *
  288.  *                                                                       *
  289.  *                                                                       *
  290.  * end of net-related stuff **********************************************
  291.  */
  292.  
  293.  
  294. /* 
  295.  * getopt(3) *************************************************************
  296.  *                                                                       *
  297.  *                                                                       *
  298.  * MIPS:                                                                 *
  299.  * This stuff is defined in the (ATT,GNU) C++ <stdlib.h>                 V
  300.  * but not in the C <stdlib.h>.
  301.  * This is the only case in which we try to compile with C,
  302.  * since this is the arch for which we have a C compiler that
  303.  * knows about prototypes.
  304.  *
  305.  * SPARCS:
  306.  * in <stdlib.h> for both gnu and ATT
  307.  * but not in C <stdlib.h>
  308.  *
  309.  * BSD:
  310.  * defined in C <stdlib.h>
  311.  * defined in ATT C++ <stdlib.h>
  312.  * (no g++ include files installed yet)
  313.  *
  314.  * AIX:
  315.  * defined in C <stdlib.h> under #ifdef _XOPEN_SOURCE
  316.  * not defined in any C++ include files.
  317.  */
  318. #ifndef __cplusplus
  319.     extern int getopt PROTO((int, const char* [], const char*));
  320. #endif
  321. extern char *optarg;
  322. extern int optind, opterr;
  323.  
  324. /* 
  325.  *                                                                       ^
  326.  *                                                                       *
  327.  *                                                                       *
  328.  *                                                                       *
  329.  * end of getopt(3) ******************************************************
  330.  */
  331.  
  332. /* 
  333.  * SYS V shared memory ***************************************************
  334.  *                                                                       *
  335.  *                                                                       *
  336.  *                                                                       *
  337.  *                                                                       V
  338.  */
  339.  
  340.  
  341. #if (defined(__GNUC__)||defined(BSD_MAKE)) && !defined(hpux)
  342.  
  343.  
  344. /* Gnu library (except on hpux) doesn't have any of the SYS V shared memory stuff */
  345.  
  346. #include "/usr/include/sys/ipc.h"
  347.  
  348. #define shmget __shmget
  349. #define shmat __shmat
  350. #define shmctl __shmctl
  351. #define shmdt __shmdt
  352.  
  353. #    if    defined(sparc)
  354. #        define KERNEL
  355. #        include "/usr/include/sys/shm.h"
  356. #        undef KERNEL
  357. #    else
  358. #        include "/usr/include/sys/shm.h"
  359. #    endif
  360.  
  361. #undef shmget 
  362. #undef shmat
  363. #undef shmctl
  364. #undef shmdt
  365.  
  366. BEGIN_EXTERNC
  367.     int shmget PROTO((key_t, int, int));
  368.     char *shmat PROTO((int, void*, int));
  369.     int shmctl PROTO((int, int, struct shmid_ds *));
  370.     int shmdt PROTO((const void*));
  371. END_EXTERNC
  372. #define semctl ______semctl
  373. #define semget ______semget
  374. #define semop ______semop
  375.  
  376. #include "/usr/include/sys/sem.h"
  377.  
  378. #undef semget
  379. #undef semop
  380. #undef semctl
  381.  
  382. #if    defined(mips)
  383.     /* g++ on mips does not have semun defined */
  384.     union semun {
  385.         int val;
  386.         struct semid_ds *buf;
  387.         ushort *array;
  388.     }; 
  389. #endif
  390.  
  391. BEGIN_EXTERNC
  392.     int semget PROTO((key_t, int, int));
  393.     int semctl PROTO((int, int, int, union semun));
  394.     int semop PROTO((int, struct sembuf *, int));
  395. END_EXTERNC
  396.  
  397.  
  398. #else
  399.  
  400. /* the NORMAL way! */
  401.  
  402. #include <sys/ipc.h>
  403. #include <sys/sem.h>
  404. #include <sys/shm.h>
  405.  
  406. #endif 
  407. /* 
  408.  *                                                                       ^
  409.  *                                                                       *
  410.  *                                                                       *
  411.  *                                                                       *
  412.  * end of SYS V shared memory  *******************************************
  413.  */
  414.  
  415.  
  416. /*
  417.  * This has to be included AFTER ipc, SYS V shared mem stuff (grot)
  418.  */
  419. #if    defined(hpux)
  420. #    include <sys/wait.h>
  421. #endif /* hpux */
  422.  
  423. #endif __SYSDEFS_H__
  424.